<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php 
	$ci = & get_instance();
	if(!isUserLogin()){
		redirect(site_url());exit();
	}
	$USER = $ci->user_entity->init('id', getUserId());
	$closed_tournament_array = $ci->tournament_entity->getTournamentByStatus("closed");
	
	$info_array = array();
	foreach($closed_tournament_array as $t){
	 
		$myRank = $ci->user_tournament_entity->myRankInTournament($USER->getId(), $t->id);
		foreach($ci->prize_entity->getArrayListOfPrize($t->id) as $item){
			if( $myRank == $item->rank){
				$info_array[] = array('tournament_id'=>$t->id, 'rank'=>$myRank ,'prize_id'=>$item->id);
			}
		}
	
	}
	
	 
?>

<style>
	
	table.summary{width:99%;float:left;margin-top:15px;border:1px solid #cfcfcf;}
	table.summary thead td{font-weight:bold;padding-left:10px;background:#eeeeee;border-right:1px solid #cfcfcf;border-bottom:1px solid #cfcfcf;}
	table.summary tbody td{padding-left:10px;border:1px solid #cfcfcf;}
	table tbody tr:nth-child(2n){background:#fff;}
</style>

<div id="center_content">
	<div class="clrboth"></div>
	<div class="block">
		<div class="title" style="position:relative;">
			<h3 class="bold"><a href="<?php echo site_url("cricket/user/dashboard")?>">Dashboard</a> &raquo; Shipping Status</h3>
			<a class="back_button2" href="<?php echo site_url("cricket/user/dashboard")?>" title="Back?">Back?</a>	
		</div>
		<div class="clrboth"></div>
		<div class="content">
			<div class="rowitem3">
				<div class="clrboth"></div>
				
				<table class="summary">
					<thead>
						<td width="20%">Tournament name</td>
						<td width="20%">Prize</td>
						<td width="10%">Courier</td>
						<td width="15%">Shipping date</td>
						<td width="15%">Tracking No.</td>
						<td width="20%">Description</td>
					</thead>	
					<tbody>
						<?php foreach($info_array as $item):?>
							<?php 
								$TOURNAMENT = $ci->tournament_entity->init( 'id', $item['tournament_id'] );
								$PRIZE = $ci->prize_entity->init( 'id', $item['tournament_id'] );
							?>
							<tr>
								<td><?php echo $TOURNAMENT->getName();?></td>
								<td><?php echo $PRIZE->getPrizeName();?></td>
								<td><?php echo $PRIZE->getCourierName();?></td>
								<td><?php if($PRIZE->getShippingDate()) echo sysDateTimeFormat($PRIZE->getShippingDate(), 'Y-m-d' );?></td>
								<td><?php echo $PRIZE->getTrackingNo();?></td>
								<td><?php echo $PRIZE->getDescription();?></td>
							</tr>
						<?php endforeach;?>
					</tbody>
				</table>

				<div class="clrboth"></div>		
			</div>	
			<div class="clrboth"></div>
		</div>
	</div>	
	<div class="clrboth"></div>
</div>	
